package com.wechat.controller;

import com.alibaba.fastjson.JSONObject;
import com.fh.modules.oms.vo.ShoppingCarVo;
import com.fhMall.request.QueryShoppingCarRequest;
import com.wechat.feign.FhEmalShoppingCarApi;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 
 *
 * @author 
 * @date 2019-09-18 20:00:31
 */
@RestController
@RequestMapping("wechat/shoppingCar")
@Api(tags = "")
public class WechatShoppingCarController extends BaseController{

    @Autowired
    private FhEmalShoppingCarApi fhEmalShoppingCarApi;

    @ApiOperation(value = "购物车列表")
    @GetMapping(value = "/queryShoppingCarList")
    public JSONObject queryShoppingCarList(
                                             @ApiParam("页数") @RequestParam(defaultValue = "1") Integer pageNo,
                                             @ApiParam("个数") @RequestParam(defaultValue = "10") Integer pageSize) {
        Integer memeberId=this.getUserId();
        String result = fhEmalShoppingCarApi.queryShoppingCarList(this.getUserId(), pageNo, pageSize);
        return JSONObject.parseObject(result);
    }

    /**
     * 添加购物车
     * @return 添加购物车
     */
    @ApiOperation(value="添加购物车")
    @PostMapping(value = "/saveShoppingCar")
    public JSONObject saveShoppingCar(@RequestBody ShoppingCarVo shoppingCarVo) {
        shoppingCarVo.setMemberId(this.getUserId());
        String result = fhEmalShoppingCarApi.saveShoppingCar(shoppingCarVo);
        return JSONObject.parseObject(result);
    }

    /**
     * 批量删除购物车
     * @return 批量删除购物车
     */
    @ApiOperation(value="添加购物车")
    @DeleteMapping(value = "/deleteBatch")
    public JSONObject deleteBatch(@RequestParam(name = "ids") String ids) {
        String result = fhEmalShoppingCarApi.deleteShoppingCar(ids);
        return JSONObject.parseObject(result);
    }

}
